home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / Holy Moley / HolyMoley.jar / HolyMoley.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-09-28  |  3.0 KB  |  155 lines

  1. import java.util.Random;
  2. import javax.microedition.lcdui.Command;
  3. import javax.microedition.lcdui.CommandListener;
  4. import javax.microedition.lcdui.Display;
  5. import javax.microedition.lcdui.Displayable;
  6. import javax.microedition.midlet.MIDlet;
  7.  
  8. public class HolyMoley extends MIDlet implements CommandListener, Runnable {
  9.    // $FF: renamed from: dp javax.microedition.lcdui.Display
  10.    private Display field_0 = Display.getDisplay(this);
  11.    private static Random rand = new Random();
  12.    // $FF: renamed from: ex javax.microedition.lcdui.Command
  13.    private Command field_1 = new Command("Exit", 1, 3);
  14.    private Command start = new Command("Start", 1, 2);
  15.    private Command Pause = new Command("Pause", 1, 2);
  16.    private Command Resume = new Command("Resume", 1, 3);
  17.    private boolean play;
  18.    // $FF: renamed from: hc HC
  19.    private HC field_2 = new HC();
  20.    // $FF: renamed from: mx MsgBox
  21.    private MsgBox field_3 = new MsgBox();
  22.    private Title ttl = new Title();
  23.    // $FF: renamed from: sn int
  24.    private int field_4;
  25.    private int speed;
  26.  
  27.    public HolyMoley() {
  28.       this.field_2.addCommand(this.Resume);
  29.       this.field_2.addCommand(this.Pause);
  30.       this.field_2.setCommandListener(this);
  31.       this.field_3.addCommand(this.field_1);
  32.       this.ttl.addCommand(this.field_1);
  33.       this.ttl.addCommand(this.start);
  34.       this.ttl.setCommandListener(this);
  35.       Title.mT = 2;
  36.       this.field_0.setCurrent(this.ttl);
  37.       this.ttl.repaint();
  38.    }
  39.  
  40.    public void commandAction(Command var1, Displayable var2) {
  41.       if (var1 == this.field_1) {
  42.          this.destroyApp(false);
  43.          ((MIDlet)this).notifyDestroyed();
  44.       } else if (var1 == this.start) {
  45.          this.firstStart();
  46.       } else if (var1 == this.Pause) {
  47.          this.pauseApp();
  48.       } else if (var1 == this.Resume) {
  49.          this.startApp();
  50.          this.restartThread();
  51.       }
  52.  
  53.    }
  54.  
  55.    public void destroyApp(boolean var1) {
  56.    }
  57.  
  58.    public void firstStart() {
  59.       this.field_2.init();
  60.       this.field_4 = 0;
  61.       this.speed = 60;
  62.       HC.playSt = true;
  63.       this.play = true;
  64.       Thread var1 = new Thread(this);
  65.       var1.start();
  66.    }
  67.  
  68.    public void pauseApp() {
  69.       this.play = false;
  70.    }
  71.  
  72.    public void restartThread() {
  73.       Thread var1 = new Thread(this);
  74.       var1.start();
  75.    }
  76.  
  77.    public void run() {
  78.       if (this.play) {
  79.          do {
  80.             this.threadP(this.speed);
  81.             if (this.field_4 == 0) {
  82.                this.startSet();
  83.             }
  84.  
  85.             this.field_2.repaint();
  86.             if (HC.gameover) {
  87.                this.threadP(800);
  88.                Title.mT = 3;
  89.                int var1 = this.field_2.returnS();
  90.                Title.mscore = var1;
  91.                this.field_0.setCurrent(this.ttl);
  92.                this.ttl.repaint();
  93.                this.play = false;
  94.                HC.playSt = false;
  95.             } else if (!HC.playSt) {
  96.                this.play = false;
  97.                HC.playSt = false;
  98.                this.threadP(800);
  99.                MsgBox.mT = 1;
  100.                MsgBox.life = this.field_2.returnH();
  101.                this.field_0.setCurrent(this.field_3);
  102.                HC.score += 10 * this.field_2.returnH();
  103.                this.threadP(2000);
  104.                if (this.field_4 == 6) {
  105.                   Title.mT = 1;
  106.                   int var2 = this.field_2.returnS();
  107.                   Title.mscore = var2;
  108.                   this.field_0.setCurrent(this.ttl);
  109.                   this.ttl.setCommandListener(this);
  110.                   this.ttl.repaint();
  111.                   this.play = false;
  112.                   HC.playSt = false;
  113.                } else {
  114.                   this.startSet();
  115.                }
  116.             }
  117.          } while(this.play);
  118.  
  119.       }
  120.    }
  121.  
  122.    public void startApp() {
  123.       this.play = true;
  124.    }
  125.  
  126.    public void startSet() {
  127.       ++this.field_4;
  128.       HC.stnum = this.field_4;
  129.       this.speed -= 10;
  130.       if (this.speed < 0) {
  131.          this.speed = 0;
  132.       }
  133.  
  134.       this.field_3.setCommandListener(this);
  135.       MsgBox.stgNum = this.field_4;
  136.       MsgBox.mT = 0;
  137.       this.field_0.setCurrent(this.field_3);
  138.       this.field_3.repaint();
  139.       this.threadP(1500);
  140.       this.play = true;
  141.       HC.playSt = true;
  142.       this.field_0.setCurrent(this.field_2);
  143.       this.field_2.startSet();
  144.       this.field_2.repaint();
  145.    }
  146.  
  147.    public void threadP(int var1) {
  148.       try {
  149.          Thread.sleep((long)var1);
  150.       } catch (InterruptedException var2) {
  151.       }
  152.  
  153.    }
  154. }
  155.